"use server";
import Title from "antd/es/typography/Title";
import {Divider, Flex, message} from "antd";
import "./index.css";
import {listQuestionBankVoByPageUsingPost} from "@/api/questionBankController";
import QuestionBankList from "@/components/QuestionBankList";

/**
 * 主页
 * @constructor
 */
export default async function BankPage() {
  let questionBankList = [];

  try {
    const result = await listQuestionBankVoByPageUsingPost({
      pageSize: 200,
      sortField: "createTime",
      sortOrder: "descend",
    });
    questionBankList = result.data.records ?? [];
  } catch (e) {
    message.error("获取题库列表失败，" + e.message);
  }



  return (
    <div id="bankPage" className={"max-width-content"}>
      <Title level={3}>
        <Flex justify="space-between" align="center">
          <Title level={3}>全部题库</Title>
        </Flex>
      </Title>
      <div>
        <QuestionBankList questionBankList={questionBankList} />
      </div>
      <Divider />

    </div>
  );
}
